package com.stevlu.common;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Steven Lu on 2018/11/21.
 */
public class DateConverter implements Converter<String, Date> {
	private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	public Date convert(String s) {
		if ("".equals(s) || s == null) {
			return null;
		}
		try {
			return simpleDateFormat.parse(s);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
}